<template>
    <div v-drag="layer.show">
        <el-dialog v-model="layer.show" :title="layer.title" :width="layer.width" center>
            <slot></slot>

            <template v-if="layer.showButton" #footer>
                <div>
                    <el-button type="primary" @click="confirm">确认</el-button>
                    <el-button @click="close">取消</el-button>
                </div>
            </template>
        </el-dialog>
    </div>
</template>

<script setup>
const emits = defineEmits([ "confirm" ])
const props = defineProps({
    layer: {
        type    : Object,
        default : () => {
            return {
                show      : false,
                title     : "",
                showButton: false,
            }
        },
        required: true,
    },
})

function confirm(){
    emits("confirm")
}

function close(){
    props.layer.show = false
}
</script>

<style lang="scss" scoped>

</style>
